package com.efast.dmom.mgmt.controller.mes;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.entity.mes.PmVehicleSeriesAndModel;
import com.efast.dmom.mgmt.service.mes.PmVehicleSeriesAndModelService;

@Controller
@RequestMapping("/seriesAndModel")
public class PmVehicleSeriesAndModelController {
	
	@Autowired
	private PmVehicleSeriesAndModelService vehicleSeriesAndModelService ;
	
	@RequestMapping(value = "/saveVehicleSeries", method=RequestMethod.POST)
	public @ResponseBody ResultBean saveVehicleSeries(@RequestBody PmVehicleSeriesAndModel enti) {

		ResultBean result = new ResultBean(true, "'");
		result.setSuccess(true);
		ResultBean resultBean = vehicleSeriesAndModelService.saveVehicleSeries(enti);
		if(!resultBean.success) {
			result.setSuccess(false);
			result.setMessage(resultBean.message);
			return result;
		}
		return result;

	}

	@RequestMapping(value = "/saveVehicleModel", method=RequestMethod.POST)
	public @ResponseBody ResultBean saveVehicleModel(@RequestBody PmVehicleSeriesAndModel enti) {

		ResultBean result = new ResultBean(true, "'");
		result.setSuccess(true);
		ResultBean resultBean = vehicleSeriesAndModelService.saveVehicleModel(enti);
		if(!resultBean.success) {
			result.setSuccess(false);
			result.setMessage(resultBean.message);
			return result;
		}
		return result;

	}
	@RequestMapping(value = "/deleteVehicleSeries", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteVehicleSeries(@RequestBody PmVehicleSeriesAndModel enti) {

		ResultBean result = new ResultBean(true, "'");
		result.setSuccess(true);
		vehicleSeriesAndModelService.deleteVehicleSeriesById(enti.getVehicleSeriesId());

		return result;

	}
	@RequestMapping(value = "/deleteVehicleModel", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteVehicleModel(@RequestBody PmVehicleSeriesAndModel enti) {

		ResultBean result = new ResultBean(true, "'");
		result.setSuccess(true);
		vehicleSeriesAndModelService.deleteVehicleModelById(enti.getVehicleModelId());

		return result;

	}

}
